package org.syslog;

import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;

public class SendLog {
	private static Logger LOG = Logger.getLogger(SendLog.class);
	

	private static long getPID() {
		String processName = java.lang.management.ManagementFactory
				.getRuntimeMXBean().getName();
		return Long.parseLong(processName.split("@")[0]);

	}

	public static void main(String[] args) throws ParseException {
		final String s = "<167>1 2012-07-04T15:15:26.898861+08:00 15.44.19.11 2012-07-04 - - - 15:15:26,897 [Thread-4] DEBUG org.apache.hadoop.hdfs.DFSClient- computePacketChunkSize: src=/flume/20120704/bcp_.266734118681352.lzo_deflate.tmp, chunkSize=516, chunksPerPacket=127, packetSize=65557";

		Pattern c = Pattern.compile("<(.+)>\\d\\s+(\\S+)\\s+(\\S+)\\s+(.*)");
		Matcher matcher = c.matcher(s);
		if (matcher.find()) {
			//System.out.println(matcher.group());
		}


		while (true) {

			LOG.info("我爱北京天安门，这是一条日志" + getPID());

			try {
				Thread.sleep(2000);

			} catch (Exception e) {
				e.getStackTrace();
				e.printStackTrace();
			}
		}

	}
}
